package com.situ.service.impl;
import java.util.List;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import com.situ.service.StorageService;
import com.situ.dao.StorageDao;
import com.situ.common.Assist;
import com.situ.entity.Storage;
/**
 * Storage的服务接口的实现类
 * 
 * @author 胡文 qq:986776
 *
 */
@Service
public class StorageServiceImpl implements StorageService {
	private final Logger LOG = LogManager.getLogger(this.getClass());

	@Autowired
	private StorageDao storageDao;

/**
* 查询....
*/
	@Override
	public List<Storage> find(Storage value) {

		List<Storage> result = storageDao.selectStorageByObj(value);

		return result;
	}
@Override
	public List<Storage> find2(Storage value) {

		List<Storage> result = storageDao.selectStorageByObj2(value);

		return result;
	}

/**
* 添加不为空
*/
	@Override
	public Storage saveNotNull(Storage value) {
		if (value == null) {
			if (LOG.isDebugEnabled()) {
				LOG.debug("执行将Storage中属性值不为null的数据保存到数据库-->失败:对象不能为空");
			}
			return value;
		}
		if(value.getStk_id() == null || value.getStk_prod_id() == null || value.getStk_warehouse() == null || value.getStk_ware() == null || value.getStk_count() == null  ){
			if (LOG.isDebugEnabled()) {
				LOG.debug("执行将Storage中属性值不为null的数据保存到数据库-->失败:存在不能为空的空值");
			}
			return value;
		}
		int result = storageDao.insertNotNullStorage(value);
		if (LOG.isDebugEnabled()) {
			LOG.debug("执行将Storage中属性值不为null的数据保存到数据库-->结果:", result);
		}
		return value;
	}


}